package com.hmt.pharmacy.api.result.enums;

import lombok.Getter;

/**
 * @author: huza
 * @createTime: 2024/8/11
 */
@Getter
public enum ResultEnum {
    
    // 默认成功
    SUCCESS(0, "操作成功！", true),
    
    // 默认失败
    FAIL(-1, "操作失败，请联系管理员！", false),
    
    /* 参数错误 */
    PARAM_IS_INVALID(10001, "参数无效", false),
    PARAM_IS_BLANK(10002, "参数为空", false),
    PARAM_TYPE_BIND_ERROR(10003, "参数格式错误", false),
    PARAM_NOT_COMPLETE(10004, "参数缺失", false),
    
    /* 用户错误：20001-29999*/
    USER_NOT_LOGGED_IN(20001, "用户未登录，请先登录", false),
    USER_LOGIN_ERROR(20002, "账号不存在或密码错误", false),
    USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用", false),
    USER_NOT_EXIST(20004, "用户不存在", false),
    USER_HAS_EXISTED(20005, "用户已存在", false),
    
    /* 系统错误：40001-49999 */
    FILE_MAX_SIZE_OVERFLOW(40003, "上传尺寸过大", false),
    FILE_ACCEPT_NOT_SUPPORT(40004, "上传文件格式不支持", false),
    
    /* 数据错误：50001-599999 */
    RESULT_DATA_NONE(50001, "数据未找到", false),
    DATA_IS_WRONG(50002, "数据有误", false),
    DATA_ALREADY_EXISTED(50003, "数据已存在", false),
    AUTH_CODE_ERROR(50004, "验证码错误", false),
    
    /* 权限错误：70001-79999 */
    PERMISSION_UNAUTHENTICATED(70001, "此操作需要登陆系统！", false),
    PERMISSION_UNAUTHORIZED(70002, "权限不足，无权操作！", false),
    PERMISSION_EXPIRE(70003, "登录状态过期！", false),
    PERMISSION_TOKEN_EXPIRED(70004, "token已过期", false),
    PERMISSION_LIMIT(70005, "访问次数受限制", false),
    PERMISSION_TOKEN_INVALID(70006, "无效token", false),
    PERMISSION_SIGNATURE_ERROR(70007, "签名失败", false);
    
    // 响应码
    int code;
    // 提示信息
    String message;
    // 成功状态
    boolean success;
    
    ResultEnum(int code, String message, boolean success) {
        this.code = code;
        this.message = message;
        this.success = success;
    }
    
    public int code() {
        return code;
    }
    
    public String message() {
        return message;
    }
    
    public boolean success() {
        return success;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public void setSuccess(boolean success) {
        this.success = success;
    }
}
